--local Dict = require("core.BSDict")

local Dict
local Banshu = require("common.Banshu")
if Banshu.IS_BANSHU then
  Dict = require("core.BSDict")
else
  Dict = require("core.Dict")
end



local dict_maxx = 0
for k in pairs(Dict) do
	if type(k) == "string" then
		local klen = #k
		if klen < 1 then
			assert()
		end
		if dict_maxx < klen then
			dict_maxx = klen
		end
	end
end

local tb = {}
function filter(a, dict)
	dict = dict or Dict
	local tblen = 0
	local i = 1
	local alen = #a
	local ac
    local l1 = 0
    for k in pairs(Dict) do
        l1 = l1 + 1
        if l1 > 10 then
            break
        end
    end
	while i <= alen do
		local j = math.min(alen, i + dict_maxx - 1)
		while i <= j do
            local nStr = string.sub(a, i, j)
			if dict[nStr] == true then
				break
			end
			j = j - 1
		end
		if j < i then
			tblen = tblen + 1
			tb[tblen] = string.sub(a, i, i)
			i = i + 1
		else
			ac = true
			tblen = tblen + 1
			tb[tblen] = "*"
			i = j + 1
		end
	end
	if not ac then
		return a
	end
	local b = table.concat(tb, nil, 1, tblen)
	return b
end

local fk_letter = {
"[", "]", "\\", "\"", "'", "/", " ", "　", "@", "&", "`", "~", "$", "%", "^", "*", "(", ")", "-", "{", "}", ":", ";", "|", "<", ">", "?", ".", "=", "梦楹上仙", "春茗仙子", "太白星君", "云桂真君", "官方"}
function filter_name(name)
	for _, v in ipairs(fk_letter) do
		if string.find(name, v, 1, true) then
			return
		end
	end
	return filter(name)
end
